package com.pgybook.front.web.interceptors;

import com.pgybook.db.entity.domain.Province;
import com.pgybook.front.service.GoeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: feeling
 * Date: 13-11-22
 * Time: 上午12:05
 */
public class GoeInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        List<City> city = cityDao.findByCriteria();
        List<Province> province = goeSrv.getProvinces();
//        List<CityDistrict> cityDistrict = cityDistrictDao.findByCriteria();
//        if(!Hibernate.isInitialized(province)){
//            Hibernate.initialize(province);
//        }
        request.setAttribute("province", province);
        return true;
    }


//    @Autowired
//    CityDao cityDao;
//
//    @Autowired
//    CityDistrictDao cityDistrictDao;

    @Autowired
    GoeService goeSrv;
}
